<template>
  <div class="form-item">
    <div class="item-label">{{ label }}</div>
    <div class="item-content">
      <textarea class="form-textarea" v-model="text" :readonly="readonly"/>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    label: {
      type: String,
      default: "",
    },
    value: {
      type: String,
      default: "",
    },
    readonly: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      text: this.value,
    };
  },
  watch: {
    value(newVal) {
      this.text = newVal;
    },
    text(newVal) {
      this.$emit("input", newVal);
    },
  },
};
</script>
<style lang="less" scoped>
.form-item {
  display: flex;
  flex-direction: column;
  min-height: 36px;
  padding: 7px 0;
  margin: 0 15px;
  border-bottom: 1px solid #f2f2f2;
  .item-label {
    line-height: 36px;
    font-size: 14px;
    color: #011445;
    opacity: 0.6;
    margin-right: 15px;
  }
  .item-content {
    flex: 1;
  }
}
.form-textarea {
  width: 100%;
  max-width: 100%;
  min-width: 100%;
  display: block;
  min-height: 60px;
  line-height: 20px;
  border: 0;
  text-align: justify;
  box-sizing: border-box;
  outline: none;
  font-size: 14px;
  text-indent: 2em;
  color: #011445;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
</style>